<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ include file="/includes/taglibs.jsp"%>
<%@ taglib uri="/WEB-INF/extremecomponents.tld" prefix="ec"%>
<%@ page import="com.cq.xjms.model.User"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
    var type = '${type}';
	if(type=='del'){
		alert("此班级里有学生，不可删除！");
	}
	function del(id){
		var departmentId = $("#departmentId").val();
		window.location.href = "delClazz.action?clazz.id="+id+"&department.id="+departmentId;
	}
	function edit(id){
		window.location.href = "editClazz.action?clazz.id="+id;
	}
	function selDepartment(){
		var id = $("#instituteId").val();
		var departmentId =  '${department.id}';
		if(departmentId==null){
			departmentId = $("#departmentId").val();
		}
		$("#departmentId").find("option").remove();
		$("#departmentId").append('<option>---请选择专业---</option>');
		var action = "listDepartmentJson.action?institute.id="+id;
		$.getJSON(action,function(data){
			var json = eval(data);
			$.each(json,function(i,n){
				if(departmentId==json[i].id){
					$("#departmentId").append('<option selected value='+json[i].id+'>'+json[i].name+'</option>');
				}else{
					$("#departmentId").append('<option value='+json[i].id+'>'+json[i].name+'</option>');
				}
			})
		})
	}
	
	function selClass(id){
		var id = $("#departmentId").val();
		var action = "listClazzJson.action?department.id="+id;
		$.getJSON(action,function(data){
			var json = eval(data);
			$.each(json,function(i,n){
				$("#clazzId").append('<td class="left_title_2">'+json[i].departmentName+'</td>');
				$("#clazzId").append('<td class="left_title_2">'+json[i].code+'</td>');
				$("#clazzId").append('<td class="left_title_2">'+json[i].name+'</td>');
				$("#clazzId").append('<td class="left_title_2"><s:a href="###" onclick="edit('+json[i].id+');">修改</s:a>'+
				'<s:a href="###" onclick="del('+json[i].id+');">删除</s:a></td>');
			})
		})
	}
</script>
<%
	Object obj = request.getSession().getAttribute("login_user");
 %>
</head>
	<body onload="selDepartment();">
		<div id="man_zone">
		<form name="form" action="listClazz.action">
		 <table class="table_style" border="0" align="center"  cellpadding="3" cellspacing="1" width="950px">
		  	<tr>
		   	    <td class="left_title_1" >
	   	    		学院：<select id="instituteId" onchange="selDepartment();" name="institute.id">
					<option>---请选择学院---</option>
					<s:iterator value="institutes">
						<option value="${id}" <s:if test="id==institute.id">selected</s:if>>${name}</option>
					</s:iterator>
					</select>
				</td>
		   	    <td class="left_title_1">
					专业：<select id="departmentId" name="department.id">
						<option>---请选择专业---</option>
					   </select>
				</td>
		   		<td class="left_title_1">
					<input type="submit" value="查询"/>
			    </td>
		   	</tr>
		</table>
		</form>
		<br/>			
		 <table class="table_style" border="0" align="center"  cellpadding="3" cellspacing="1" width="950px">
		   	<tr>
		   	    <td class="left_title_1" >专业编号:</td>
		   	    <td class="left_title_1" >专业名:</td>
		   	    <td class="left_title_1">编号:</td>
		   		<td class="left_title_1">班级:</td>
		   		<%if(obj instanceof User){
				 %>
		   		<td class="left_title_1">操作</td>
		   		<%} %>
		   	</tr>
		   		<s:iterator value="clazzs" id="clazz" >
		   		<tr id="clazzId">
		   			<td class="left_title_2">${department.code}</td>
		   			<td class="left_title_2">${department.name}</td>
		   			<td class="left_title_2">${code}</td>
		   			<td class="left_title_2">${name}</td>
		   			<%if(obj instanceof User){
					 %>
		   			<td class="left_title_2">
		   			<s:a href="###" onclick="edit(%{#attr.clazz.id});">修改</s:a>
		   			<s:a href="###" onclick="del(%{#attr.clazz.id});">删除</s:a>
		   			</td>
		   			<%} %>
		   		</tr>
		   		</s:iterator>
		   	<tr>
		   		
		   	</tr>
		</table>
		</div>
	</body>
</html>